@extends('layouts.mainlayout')

@section('main')
<div class="panel panel-default">
    <div class="panel-body">                       
        <form class="form-horizontal" action="<?php echo asset('searchs/certificates'); ?>" method='post' id='form-results'>
            <fieldset>
                <center><legend>Tra cứu văn bằng</legend></center>
                <div class="form-group">
                    <label for="mshv" class="col-lg-3 control-label">Số hiệu văn bằng</label>
                    <div class="col-lg-9">
                        <input type="text" class="form-control" id="shvb" name="shvb" placeholder="Nhập số hiệu văn bằng">
                    </div>
                </div>
                <div class="form-group">
                    <label for="hthv" class="col-lg-3 control-label">Trình độ</label>
                    <div class="col-lg-9">
                        <select name="trinhdo" id="trinhdo" class="form-control">
                            <option value="">-- Chọn --</option>
                            @foreach ($chung_chi as $chung_chi)
                            <option value="{{{$chung_chi->id}}}">{{{$chung_chi->ten_chung_chi}}}</option>
                            @endforeach    
                        </select>

                    </div>
                </div>  
                <center><div class="form-group">
                        <div class="col-lg-12">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>Tìm kiếm</button>
                            <button type='reset' class="btn btn-default" id="btn-reset">Nhập lại</button>
                        </div>
                    </div></center>
            </fieldset>
        </form>
    </div>
</div>
<div class="panel panel-default" id='panel_ket_qua' hidden>
    <div class="panel-body" id="body_ket_qua"> 

    </div>
</div>

<div class="modal fade" id="thongtinchitiet" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" id='body_modal'>

            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function show_modal(sohieubang) {
        $('#thongtinchitiet').modal('show');
    }
    $('#form-results').submit(function(event) {
        $('#panel_ket_qua').show();
        $('#body_ket_qua').html('<img src="<?php echo asset("public/images/loading46.gif"); ?>" width="5%" style="margin-left: 50%;">');
        var shvb = document.getElementById('shvb').value;
        var trinhdo = document.getElementById('trinhdo').value;
        if (shvb == '' || trinhdo == '') {
            $('#body_ket_qua').html('<center>Không có kết quả nào</center>');
        } else {
            $.ajax({
                url: this.action,
                type: 'post',
                dataType: 'html',
                data: {
                    shvb: shvb,
                    trinhdo: trinhdo
                },
            })
                    .done(function(data) {
                        $('#body_ket_qua').html(data);
                    })
                    .fail(function() {
                        console.log("error");
                    })
                    .always(function() {
                        console.log("complete");
                    });
        }
        return false;
    });
    $('#btn-reset').click(function(event) {
        $('#panel_ket_qua').hide();
    });

</script>
@stop

